#include <gtest\gtest.h>
#include <Zaf\String\Composition.h>



TEST(Composition, HasPrefix) {

	bool result;

	//char
	result = Zaf::String::HasPrefix("", "");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix("abc", "");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix("123", "1234");
	ASSERT_EQ(false, result);

	result = Zaf::String::HasPrefix("123", "123");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix("123", "12");
	ASSERT_EQ(true, result);

	std::string str = "abc";
	std::string prefix = "ab";

	result = Zaf::String::HasPrefix(str, "ab");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix("abc", prefix);
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix(str, prefix);
	ASSERT_EQ(true, result);

	//wchar_t
	result = Zaf::String::HasPrefix(L"", L"");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix(L"abc", L"");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix(L"123", L"1234");
	ASSERT_EQ(false, result);

	result = Zaf::String::HasPrefix(L"123", L"123");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix(L"123", L"12");
	ASSERT_EQ(true, result);

	std::wstring wstr = L"abc";
	std::wstring wprefix = L"ab";

	result = Zaf::String::HasPrefix(wstr, L"ab");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix(L"abc", wprefix);
	ASSERT_EQ(true, result);

	result = Zaf::String::HasPrefix(wstr, wprefix);
	ASSERT_EQ(true, result);
}



TEST(Composition, HasSuffix) {

	bool result;

	//char
	result = Zaf::String::HasSuffix("", "");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix("abc", "");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix("abc", "bc");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix("abc", "abc");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix("abc", "df");
	ASSERT_EQ(false, result);

	std::string str = "abc";
	std::string suffix = "bc";

	result = Zaf::String::HasSuffix(str, "bc");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix("abc", suffix);
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(str, suffix);
	ASSERT_EQ(true, result);

	//wchar_t
	result = Zaf::String::HasSuffix(L"", L"");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(L"abc", L"");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(L"abc", L"bc");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(L"abc", L"abc");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(L"abc", L"df");
	ASSERT_EQ(false, result);

	std::wstring wstr = L"abc";
	std::wstring wsuffix = L"bc";

	result = Zaf::String::HasSuffix(wstr, L"bc");
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(L"abc", wsuffix);
	ASSERT_EQ(true, result);

	result = Zaf::String::HasSuffix(wstr, wsuffix);
	ASSERT_EQ(true, result);
}